Case Studies with the Contiki-NG Simulator to Design Strategies for Sensors’ Communication Optimization in an IoT-Fog Ecosystem

With the development of mobile communications and the Internet of Things (IoT), IoT devices have increased, allowing their application in numerous areas of Industry 4.0. Applications on IoT devices are time sensitive and require a low response time, making reducing latency in IoT networks an essential task. However, it needs to be emphasized that data production and consumption are interdependent, so when designing the implementation of a fog network, it is crucial to consider criteria other than latency. Defining the strategy to deploy these nodes based on different criteria and sub-criteria is a challenging optimization problem, as the amount of possibilities is immense. This work aims to simulate a hybrid network of sensors related to public transport in the city of São Carlos - SP using Contiki-NG to select the most suitable place to deploy an IoT sensor network. Performance tests were carried out on five analyzed scenarios, and we collected the transmitted data based on criteria corresponding to devices, applications, and network communication on which we applied Multiple Attribute Decision Making (MADM) algorithms to generate a multicriteria decision ranking. The results show that based on the TOPSIS and VIKOR decision-making algorithms, scenario four is the most viable among those analyzed. This approach makes it feasible to optimally select the best option among different possibilities.


Introduction
A Wireless Sensor Network (WSN) is composed of devices connected to the Internet of Things (IoT) with different constraints, such as memory, energy consumption, scalability, and network robustness. All these devices have specific communication roles and functions that define the network, also known as Low-Power and Lossy Network (LLN). They can be introduced in different layers of connectivity: cloud, fog, edge, or IoT devices [1]. Figure 1 shows responsive, ubiquitous, and mobile devices at the edge of the network (Edge Computing) that respond as events occur, from simple sensors and actuators to others provided with more robust computational capabilities. The connectivity between the IoT layer and the fog layer requires less computational power than the connectivity between the fog layer and the cloud.
The infrastructure, platform, and applications in fog are interrelated, and their respective computational characteristics are distinct between the layers. Together they represent a stacked architecture in which the data is pre-processed locally and then diffused to the adjacent upper layers. Cloud computing is essential for IoT to be globally available and to increase its processing capacity. However, it is possible to use fog computing architecture to provide services while keeping latency low, reducing network load, and improving energy efficiency [3].
Fog computing has evolved as a promising solution that can bring cloud applications closer to IoT devices near the edge of the network, which is a characteristic that contributes to low latency and lower response time [4]. However, fog computing also introduces constraints in this service layer, such as ensuring that its services are efficiently available to different IoT devices since they have limitations and present new challenges regarding the computational and energy resources used.
This increase in the number of built IoT devices has boosted research about applications for areas such as traffic surveillance [5,6], environmental monitoring [7,8], smart cities [9][10][11], intelligent transport systems [12], and agriculture [13,14]. These applications require a reconfigurable architecture and environments that require different computing resources that can be used more efficiently at the edge of the network. Furthermore, according to the authors [15], "the location selected to install sensors significantly affects the amount of information extracted from the measured data".
Several gateway architectures have been proposed over the years to manage multiple sensors. However, performance concerns are related to high communication latency or variations in traffic load demands on networks generated through device mobility. Therefore, some studies introduce IoT concepts with fog computing to deploy applications targeting placement, distribution, scalability, device density, or mobility support [16].
Urban mobility services have as their essence the use of IoT technologies. Some research focuses on proposing a model to select the correct subset of buses that maximizes the coverage of a city [17]. Others solve linear optimization problems related to vehicles that follow predetermined routes and, as a solution, propose strategies that use heuristics [18]. Finally, we can mention research that has the purpose of collecting data from sensors coupled to buses [19].
Multi-attribute decision-making methods are widely used to solve problems of fog node selection and fog gateway selection. Different Multiple Attribute Decision Making (MADM) algorithms, including SAW, TOPSIS, and VIKOR, are used to compose a rank among the existing alternatives.
In this work, we describe and analyze the application of the Simple Additive Weighting (SAW), Technique for the Order of Prioritization by Similarity to Ideal Solution (TOPSIS) and VIseKriterijumska Optimizacija I Kompromisno Resenje (VIKOR) algorithms in metrics related to network, application and IoT device. Thus, selecting the most viable place to deploy a set of IoT sensors belonging to an LLN in fog for the public transport service of São Carlos in São Paulo, Brazil, is possible.
The selection of IoT devices often does not consider characteristics related to infrastructure, implantation strategies, or optimization metrics. As a result, our contribution focuses on the following:

•
Define the best location among the evaluated scenarios to install a set of IoT devices to a network based on MADM methods. • Maximize the supported data load of the proposed fog network for the urban mobility scenario with low communication latency.

Related Work
Determining the most suitable location to install a set of IoT devices from a fog network based on multiple criteria is both important and challenging. Because this particularity directly impacts the efficiency of the fog network, making it possible to reduce costs associated with its implementation and maintenance [20]. Considering aspects related to processing power, energy consumption, and network communication are also essential. Due to this context, research has been aimed at optimizing a single-objective value [21], studies dealing with bi-objective values [22,23], and research dealing with problems that include deciding on multiple objectives.
However, single-objective optimization proposes to optimize only one objective, while several critical metrics can be underestimated. Therefore, we should consider multiobjective optimizations for the real world to be applied in environments involving NP-hard problems. In [24], a study is proposed for approaches based on services, resources, and fog applications to be applied in smart cities. The authors list the most relevant metrics based on a revised literary study.
Multicriteria decision-making algorithms (MCDM) solve problems involving a finite number of alternatives according to the characteristics of each method. In the IoT context, different MCDM techniques have been used. MADM approaches are applied in various application domains; for example, in the article [25], the authors propose a strategy that uses the Pareto Optimal technique to compare the selection quality of the SAW, TOPSIS, and VIKOR algorithms related to specific criteria of IoT devices.
They are also commonly used to select cloud services; for example, in the article [26], the authors apply MCDM methods to the problem of choosing geographic regions for the Amazon Web Service cloud. In addition, a comparative analysis of the obtained ranking is carried out and verified both the time complexity of the different MCDM methods applied and the robustness of the classification methods. In the article [27], the AHP method is used in conjunction with fuzzy logic to classify cloud services. A hybrid multi-attribute decision-making (MADM) model is assigned to decrease the execution time of the ranking of cloud services.
In the article [28], the authors propose an integrated MCDM approach based on TOP-SIS and Best Worst Method (BWM) that uses evaluation criteria to classify the Cloud Service Provider according to the fulfillment of the customer's requirements. The article [29] focuses on problems that evaluate and rank IoT applications using AHP and SAW algorithms. In the paper [30], the authors propose a more effective recommendation system to present IoT applications. Initially, they apply the AHP algorithm to evaluate and classify IoT applications. Then they assign a sequential quadratic programming algorithm to automatically find the optimal weight of the criteria and sub-criteria.
Other studies apply heterogeneous network selection mechanisms for the Internet of Vehicles (IoV) [31], and others expose a comparative study between fuzzy AHP and fuzzy TOPSIS techniques for the reliable and connected selection of cluster leaders in a mobile wireless sensor network [32]. In the article [33], a hybrid decision-making algorithm is implemented by merging the Fuzzy Analytic Hierarchy Process (FAHP) and Dynamic Analytic Hierarchy Process (DAHP) algorithms to be applied to Intelligent Transport Systems. Finally, we mention the article [34], which uses optimization methods for network selection based on various criteria covering quality of service, mobility, cost, energy, battery life, etc.
When analyzing Table 1, we observed that MADM methods are applied in different optimization problems over the available alternatives characterized by multiple, often conflicting, attributes. This list is not comprehensive but only representative. We mainly considered reviews or research articles in the context of our study.

Multiple Criteria Decision Making
Multi-criteria decision-making (MCDM) refers to choosing the best alternative among a finite set of decision alternatives that are affected by different, often conflicting, multiple criteria [35]. Based on the number of alternatives under consideration, the MCDM can be classified into: • Multi-Attribute Decision Making (MADM): It is suitable for evaluating discrete decision spaces with predetermined decision alternatives. The MADM approach requires selecting a predetermined and limited number of decision alternatives. In addition to sorting and ranking, MADM approaches can be seen as alternative methods for combining information in a problem's decision matrix with additional information from the decision maker to determine a final ranking or selection from among the alternatives [36].  Multi-attribute decision-making algorithms are used in optimization problems that can be classified into scheduling, allocation, placement, offloading, load balancing, resource provisioning, selection, and others [37].
This article focuses on how to efficiently deploy devices in a fog network to efficiently service requests related to devices integrated into a public transport network based on multiple criteria and sub-criteria. The criteria may be dynamic or static and require maximization or minimization. For example, the latency criteria are related to network conditions and load. It is a dynamic criterion that must be minimized.
Many MADM techniques are presented in the literature, but the SAW, VIKOR, and TOP-SIS methods are well-known and involve a simple computational process. The proposed methodology makes it possible to determine the location to deploy IoT sensors that best suit your circumstances and needs. However, it does not provide a universal and definitive solution. A brief description of each method is presented in the following subsections.

Simple Additive Weighting (SAW)
According to authors [38,39], the central concept of this method is to find the weighted sum of the performance evaluations of each alternative in all attributes, which requires the normalization process of the decision matrix (X) to a scale comparable to all alternatives to existing assessments.
This method is also referred to as the simplest and easiest to use among MADM methods. Mathematical formulation [40,41] is described to the following: 1.
The criteria used as a reference in the decision are specified and named in (C i ); 2.
It is necessary to determine the adjustment value of each alternative in each attribute; 3.
Make decisions based on the criteria in the array (C i ). The matrix is normalized according to the fitted equations for the attribute type (attribute or attribute benefit costs) to obtain the normalized matrix; 4.
The final result is obtained from the multiplication process of the classification matrix, which is the sum of the normalized R with the weight vector. This way, the highest value is obtained and selected as the best alternative (A i ) for the solution.
If j is an attribute benefit, we have Equation (1).
If the attribute j is the cost, then use the formula (2). Observation: r ij = Normalized value of the performance evaluation; X ij = obtained value attribute.

Criterion:
Max X ij = highest value obtained from each criterion; Min X ij = lowest value obtained from each criterion; Benefit = If the highest value is the best value; Cost = If the lowest value is the best value.
In the equation presented in (3), we have that, r ij is the value to be classified of the alternative A i in the attribute C j ; i = 1, 2 . . . , m and j = 1, 2 . . . , n. The value preferences for each alternative (V i ) are given as: Observation: V i = Ranking of each alternative; W j = Weight value of each criterion; r ij = The ranked value V i shows that the highest value is the preferred alternative A i .

Technique for the Order of Prioritisation by Similarity to Ideal Solution (TOPSIS)
The authors Hwang and Yoon [42] proposed the method of demand performance based on the correlation to the optimal solution (TOPSIS). It is a method that weighs several alternatives and criteria in a generalized situation. TOPSIS describes a solution with the shortest distance to the ideal solution, defined as Positive Ideal Solution (PIS), and the most significant distance from the negative ideal solution, defined as Negative-Ideal Solution (NIS). However, it does not consider the relative importance of these distances [43].

1.
The decision matrix D is represented as The elements r ij of the ordered decision matrix are calculated according to Equation (4). 3.
To generate the weighted ordered decision matrix, the corresponding weights w n of the different criteria are multiplied with the obtained values r ij .

4.
The PIS and the NIS are formulated according to Equations (5) and (6).
The distance of each alternative is calculated from the PIS and NIS according to Equations (7) and (8).
6. The relative proximity of each alternative is calculated according to Equation (9).
Finally, the values of the proximity coefficient obtained with Equation (9) make it possible to calculate the ranking order.

VIseKriterijumska Optimizacija I Kompromisno Resenje (VIKOR)
According to [58], VIKOR "is a classification method for a finite set of alternative actions to be classified and selected among the criteria and solves a discrete multi-criteria problem with non-quantifiable and conflicting criteria".
In the work of [59], the authors show that the VIKOR method is applied in several fields, such as construction administration, material selection, performance evaluation, health, supply chain, management of tourism, quality of service, sustainability, and others.
The multi-criteria evaluation to adjust the ranking was developed from L p -metric (Equation (10)), and is used as an aggregation function in a programming adjustment method. The various alternatives of k (k = 1, . . . , n) are represented as a 1 , a 2 , . . . , a n . For alternative a k , the classification of criterion j is denoted by f kj , that is, f kj is the value of j and criterion of the function for alternative a k ; m is the number of criteria (j = 1, 2, . . . , m).
Regarding the VIKOR method, L 1,k and L ∞,k are used to formulate sorting criteria. The solution obtained by min k S k has a maximum group function ("majority" rule, shown with an average difference when p = 1), and the solution obtained by min k R k , with a minimum individual analysis of the "concurrent".
The adjustment solution F c is a feasible solution closer to the ideal of F * , and the term adjustment means an agreement established by mutual concessions, as illustrated in Figure 3. The VIKOR algorithm has the following steps: 1.
Determines the best f * j and worst f − j values of all functions and criteria, j = 1, 2, . . . , m. If function j represents a benefit, then f * j = max k f kj or adjust f * j is the desired/desired level, f − j = min k f j k being the worst-level configuration f − j .

2.
Calculate the values S k and R k , k = 1, 2, . . . , n, by the relations: . . , m}, shows how the maximum distance to priority improves, where w j are the criteria weights.

3.
Calculates the value Q j , k = 1, 2, . . . , n, by the relation where: S * = min k S k or leave S * = 0, desired level; S − = max k S k or leave S − = 1, worst level; R * = min R j or leave R * = 0, desired level; It is worth mentioning that v is introduced because it is the weight of the "majority of criteria" approach (or "the maximum utility of the group"), here v = 0.5.

4.
Rank the alternatives, sorted by the values S, R, and Q, in descending order. The result is three ordered lists.

Case Study
In this section, we present the method for selecting the most suitable place to install IoT devices for a public transport network, which is simulated using Contiki-NG considering three groups of main criteria. Three MADM methods rank the different scenarios proposed for installing the devices. Some relevant points that differentiate our work from those shown in Table 1 are   • All data is collected at runtime during the simulation of the analyzed scenarios; • All sensors are emulated, so it is possible to carry out simulations with different types of sensors and obtain results closer to the real world; • The performance analysis of the fog network infrastructure is carried out before its implantation. • MADM methods are applied to multiple criteria involving different layers of the conceptual communication architecture model.

Problem Presentation
There are open questions in research related to optimization problems in fog computing. Some studies address the issue of placing nodes in fog [60][61][62], and the literature explores the benefits of using MCDM methods [37,63]. It is important to emphasize that this type of procedure is not an easy task, as many architectures, protocols, devices, criteria, and approaches are involved in its selection.
We apply MADM methods to select the most suitable location for deploying IoT devices among 5 (five) possible scenarios presented for the city of São Carlos-SP. This choice is due to the existence of a main objective for the decision maker (DM), which is to reach the most favorable solution among a set of criteria. The deployment of IoT devices, both at the interstate bus terminal and the bus stops close to it, makes it possible to collect data from many buses with lower communication latency to receive data from sensors installed on the buses.
The selection of the most viable points for the installation of IoT devices also results in the reduction of future costs related to a new installation, configuration, and maintenance of the sensor network, in addition to directly impacting the total data load supported by the network in fog. All sensors applied during the experiments were emulated in Cooja, network communication is simulated in Contiki-NG, and access to the sensors occurs through the HTTP protocol. The criteria influence the choice of the most suitable place for installing the IoT sensors and refer to the IoT (sensors), fog (network), and cloud (software) layers. The sub-criteria applied to the optimization problem are shown in Figure 4.  The maximum number of mobile sensors supported in the analyzed scenarios is 30. Above this value, there is a communication overhead. The scenarios presented in Figure 5 were divided into 2 (two) groups, one with 22 sensors and the other with 37 sensors. In both groups, seven static nodes are responsible for receiving and sending all data traffic from the fog network. Node 1 (Sink Node/Middleware) is also responsible for communication between fog and cloud networks. Six (6) simulations were performed per scenario, with a time interval of 1 hour per simulation and a total of 30 hours of simulation for each group. The data collected via Hypertext Transfer Protocol (HTTP) communication at runtime during the simulation was performed using a script developed in PHP Hypertext Preprocessor, with data being inserted into a MySQL database. Then, the arithmetic mean of each sub-criterion was obtained to populate the data table to which the decision-making algorithms were applied. All nodes were distributed within 100 m, all interconnected through a hierarchical architecture and allocated according to the geographic coordinates obtained through google maps. For each mobile node, the time of getting on and off was considered, in addition to the vehicle's movement according to the direction of the traffic of the existing streets and other routes.

The selection hierarchy process
Another essential point relates to the configuration parameters used in Contiki-NG to simulate the already presented scenarios. The parameters used to run the tests are shown in Table 2. In a scenario composed of a set of sensors, applying MADM algorithms to assist in decision-making regarding the location of these sensors is essential. The decision matrix (m × n) with the values of the m alternatives for the n criteria are present in Table 3, and the foundations of this approach are divided into three groups: • Alternatives: A set of alternatives will be classified: the five different scenarios presented in Figure 5. • Attribute set: Represents criteria used in the decision-making process. For each scenario, the sub-criteria are present in Figure 4. • Weights: The weights for the sub-criteria used in the decision process are shown in Table 3.
The algorithms SAW, TOPSIS, and VIKOR were implemented in the R programming language and generated the results via RStudio software.

Results
The SAW method provides a simple approach to obtain the normalized and weighted decision matrix. Figure 6 presents scenario two as the best rated for the group of 22 nodes and scenario 1 for the group with 37 nodes.
In decision-making, the TOPSIS method is applied to order alternatives and select the scenario that denotes the best option among the five alternatives. The decision matrix present in Table 3 is normalized using Equation (4), and the final ranking result for the analyzed scenarios is present in Figure 7, with scenario four as the best option for a group of 22 nodes. The VIKOR method considers the alternative closest to the ideal solution. Therefore, the ranking in Figure 8 presents scenario four as the best option for a group of 22 nodes.
There are limitations regarding the number of requests supported when increasing the number of nodes to 37. Specific nodes have "bad" values, that is, very low values, which directly impacts applying the SAW method to these values. Said values are considered when ranking the results, making decision-making prone to error.
The results presented in Figures 7 and 8 do not show the rank of these nodes because some have values that negatively influence the final result. This situation occurred because the data collected by these nodes suffered traffic overload, high packet loss, and increased latency in the communication between the sensors and the application layer over the HTTP protocol.
The results in Table 4 show that the SAW method tends to induce errors in decisionmaking, so it will not be considered. The most robust alternative after applying the TOPSIS and VIKOR methods for the group with 22 nodes because of the evaluated criteria and assigned weights is scenario 4.

Conclusions
The connectivity between the IoT layer and the fog layer has less computational power than the cloud, and a way to get better performance in a sensor network that encompasses IoT devices, wireless communication, and applications is through the use of algorithms of optimization. MCDM methods are successfully used in optimization problems the several areas. Because of this, we apply the SAW, VIKOR, and TOPSIS algorithms to a device positioning problem to define the most viable location for deploying an IoT sensor network.
After defining the normalized decision matrix and assigning weights to the different sub-criteria, the results show that scenario 4 is the best classified by the TOPSIS and VIKOR methods. Being the best-classified alternative by the TOPSIS method indicates that this scenario is the best in terms of classification index and for being the closest alternative to the ideal solution among the analyzed scenarios. In addition, being the best-ranked alternative by the VIKOR method indicates that it is closer to the ideal solution of the methods evaluated. Both methods have the same scenario selection reference for fog computing sensor network deployment.
It is essential to point out that MADM algorithms have relatively high complexity due to the multiple criteria considered. Therefore, it is essential to evaluate the criteria and sub-criteria more objectively. Selecting the best location using MADM techniques among the alternatives allows you to increase the accuracy of service communication and reduce costs related to future problems with the deployed infrastructure.
In the future, we propose expanding the research scope and applying MODM methods to solve device placement optimization problems on different types of sensors integrated into the network. Thus, it will be possible to deploy fog devices efficiently and offer services to massive IoT devices without violating end user Quality of Service (QoS) requirements.